package com.javatian.dao;

import com.javatian.entity.GoodsInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 商品信息Dao
 */
@Repository
public interface GoodsInfoDao extends Mapper<GoodsInfo> {

    /**
     * 根据名称查询
     */
    List<GoodsInfo> findByNameAndUserId(@Param("name")String name,@Param("userId")Long userId,@Param("level")Integer level);

    /**
     * 根据商品类型获取热门商品
     */
    @Select("select * from goods_info where typeId = #{typeId} order by hot desc limit 8")
    List<GoodsInfo> findByType(@Param("typeId")Integer typeId);

    /**
     * 推荐商品
     */
    @Select("select * from goods_info where recommend = '是'")
    List<GoodsInfo> findRecommendGoodsInfos();

    /**
     * 查询用户购买过的所有商品
     */
    List<GoodsInfo> getOrderGoods(@Param("userId")Long userId,@Param("level")Integer level);
}
